﻿package com.bizmlib.framework.abstract.mvc
{
	/**
	 * Performs as a model.
	 * @author	Valentyn Derkach
	 */
	import flash.events.*;
	import com.bizmlib.framework.abstract.mvc.*;
	import com.bizmlib.data.AbstractDataObject;
	
	
	public class AbstractModel extends EventDispatcher
	{
	
		private var __view:AbstractView;
		/**
		 * __data variable is not initialized anywhere in this class. You should do it in your own subclass.
		 */
		protected var __data:AbstractDataObject;
	
	
		public function AbstractModel()
		{
			init();
		}
	
	
		/**
		 * Getter and setter for the site's view property
		 */
		public function set view(value:AbstractView):void
		{
			__view = value;
		}
		public function get view():AbstractView
		{
			return __view;
		}
	
		/**
		 * data property getter. Override it in order to return a correct type. Check comments for the __data variable.
		 */
		public function get data():Object
		{
			return __data;
		}
		
		
		/**
		 * Performes a cleanning routine, so that a instance gets ready to be destroyed and collected by a 
		 * garbage collector.
		 * If you initialize a data property, please, clean it a overriden clean method in your subclass.
		 */
		public function clean():void
		{
			view = null;
			
			__data = null;
		}
	
	
		/**
		 * Does an initialization stuff.
		 */
		protected function init():void
		{
		}
		
		
		/**
		 * Returns a string describing of the object.
		 */
		override public function toString():String
		{
			return "[com.bizmlib.frameworks.abstract.mvc.AbstractModel]";
		}
	
	}
}